/* Copyright (c) 2011 by crossmobile.org
 *
 * CrossMobile is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, version 2.
 *
 * CrossMobile is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with CrossMobile; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

package org.xmlvm.iphone;

import android.content.Context;
import android.view.View;
import android.widget.ProgressBar;

public class UIActivityIndicatorView extends UIView {

    private int activityIndicatorViewStyle = UIActivityIndicatorViewStyle.White;
    private boolean hidesWhenStopped = true;

    public UIActivityIndicatorView() {
        this(UIActivityIndicatorViewStyle.White);
    }

    @SuppressWarnings("OverridableMethodCallInConstructor")
    public UIActivityIndicatorView(int UIActivityIndicatorViewStyle) {
        setActivityIndicatorViewStyle(UIActivityIndicatorViewStyle);
    }

    public void setActivityIndicatorViewStyle(int style) {
        this.activityIndicatorViewStyle = style;
    }

    public int getActivityIndicatorViewStyle() {
        return activityIndicatorViewStyle;
    }

    public void setHidesWhenStopped(boolean flag) {
        this.hidesWhenStopped = flag;
    }

    public boolean getHidesWhenStopped() {
        return hidesWhenStopped;
    }

    public void startAnimating() {
        if (hidesWhenStopped)
            setHidden(false);

    }

    public void stopAnimating() {
        if (hidesWhenStopped)
            setHidden(true);
    }

    @Override
    View createModelObject(Context cx) {
        ProgressBar bar = new ProgressBar(cx);
        bar.setIndeterminate(true);
        return bar;
    }
}
